package com.mozz.finally_work.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface CollectionDao {

    /*收藏文章*/
    @Insert("INSERT INTO collection (id,user_id,blog_id) values(#{id},#{userId},#{blogId})")
    Integer collectionBlog(@Param("id") String id, @Param("userId") String userId, @Param("blogId") String blogId);

    /*取消收藏*/
    @Delete("DELETE FROM collection where user_id=#{userId} and blog_id=#{blogId}")
    Integer unCollectionBlog(@Param("userId") String userId, @Param("blogId") String blogId);

    /*根据用户id查询收藏数量*/
    @Select("SELECT count(*) as collectionCount FROM collection where user_id=#{userId}")
    Integer countCollection(String userId);

    /*查看是否已收藏*/
    @Select("SELECT count(*) FROM collection where user_id=#{userId} and blog_id=#{blogId}")
    Integer isCollection(@Param("userId") String userId, @Param("blogId") String blogId);


}
